package cn.txy.service.impl;

import cn.txy.constants.UserType;
import cn.txy.mapper.LoginMapper;
import cn.txy.openfeign.UaaOpenFeign;
import cn.txy.pojo.domain.Login;
import cn.txy.pojo.domain.LoginVo;
import cn.txy.result.JSONResult;
import cn.txy.utils.NameUtil;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@Tag(name = "登录对象远程API")
class UaaOpenfeignImpl implements UaaOpenFeign {
    @Autowired
    private LoginMapper loginMapper;
    @Override
    public JSONResult register(LoginVo loginVo) {
        Login login = new Login();
        BeanUtils.copyProperties(loginVo,login);
        login.setUsername(loginVo.getPhone());
        login.setPassword("123456");
        login.setType(loginVo.getType());
        login.setEnabled(false);
        login.setAdmin(false);
        login.setNickName(NameUtil.getName());
        login.setCreateTime(new Date());
        loginMapper.insert(login);
        return JSONResult.success();
    }
}
